#!/usr/bin/python2.5
# LEAVE THE FOLLOWING TWO LINES
# GAME BAKER
# yaml
# 0
s = """
!!python/object:game.Game
gameobjects:
  Alien: !!python/object:game.GameObject
    baseworkstate: ws_alien
    name: Alien
    objtype: Gameobject
    requires: []
    sprite: alien1
  Bullet: !!python/object:game.GameObject
    baseworkstate: ws_bullet
    name: Bullet
    objtype: Gameobject
    requires: []
    sprite: bulletyellow
  Fireball: !!python/object:game.GameObject
    baseworkstate: ws_fireball
    name: Fireball
    objtype: Gameobject
    requires: []
    sprite: fireball
  MotherShip: &id002 !!python/object:game.GameObject
    baseworkstate: Mothership
    name: MotherShip
    objtype: Gameobject
    requires: []
    sprite: alien1
  Player: &id001 !!python/object:game.GameObject
    baseworkstate: ws_player
    name: Player
    objtype: Gameobject
    requires: []
    sprite: player
  Score: &id003 !!python/object:game.GameObject
    baseworkstate: ws_score
    name: Score
    objtype: Gameobject
    requires: []
    sprite: null
    x: 0
    y: 0
gamescreens:
  main: !!python/object:game.GameScreen
    color: !!python/tuple [14, 0, 66]
    dimensions: !!python/tuple [800, 600]
    objtype: Gamescreen
    startobjects:
    - *id001
    - *id002
    - *id003
initcode: ''
objtype: Game
sprites:
  alien1: !!python/object:game.Sprite
    alphakey: !!python/tuple [128, 0, 0]
    framerate: 1
    imagefiles:
    - bottomright: !!python/tuple [158, 51]
      filename: sprites/spacealiens/spritesheet.bmp
      topleft: !!python/tuple [103, 8]
    name: alien1
    objtype: Sprite
  aliendying: !!python/object:game.Sprite
    alphakey: !!python/tuple [128, 0, 0]
    framerate: 3
    imagefiles:
    - bottomright: !!python/tuple [158, 51]
      filename: sprites/spacealiens/spritesheet.bmp
      topleft: !!python/tuple [103, 8]
    - bottomright: !!python/tuple [223, 51]
      filename: sprites/spacealiens/spritesheet.bmp
      topleft: !!python/tuple [167, 9]
    name: aliendying
    objtype: Sprite
  bulletyellow: !!python/object:game.Sprite
    alphakey: !!python/tuple [128, 0, 0]
    framerate: 100
    imagefiles:
    - bottomright: !!python/tuple [18, 77]
      filename: sprites/spacealiens/spritesheet.bmp
      topleft: !!python/tuple [8, 67]
    name: bulletyellow
    objtype: Sprite
  fireball: !!python/object:game.Sprite
    alphakey: !!python/tuple [0, 0, 0]
    framerate: 2
    imagefiles:
    - bottomright: !!python/tuple [60, 42]
      filename: sprites/fireball/BlenderExplosionSmall.bmp
      topleft: !!python/tuple [0, 0]
    - bottomright: !!python/tuple [120, 42]
      filename: sprites/fireball/BlenderExplosionSmall.bmp
      topleft: !!python/tuple [60, 0]
    - bottomright: !!python/tuple [180, 42]
      filename: sprites/fireball/BlenderExplosionSmall.bmp
      topleft: !!python/tuple [120, 0]
    - bottomright: !!python/tuple [240, 42]
      filename: sprites/fireball/BlenderExplosionSmall.bmp
      topleft: !!python/tuple [180, 0]
    - bottomright: !!python/tuple [300, 42]
      filename: sprites/fireball/BlenderExplosionSmall.bmp
      topleft: !!python/tuple [240, 0]
    - bottomright: !!python/tuple [360, 42]
      filename: sprites/fireball/BlenderExplosionSmall.bmp
      topleft: !!python/tuple [300, 0]
    name: fireball
    objtype: Sprite
  player: !!python/object:game.Sprite
    alphakey: !!python/tuple [128, 0, 0]
    framerate: 100
    imagefiles:
    - bottomright: !!python/tuple [83, 46]
      filename: sprites/spacealiens/spritesheet.bmp
      topleft: !!python/tuple [28, 13]
    name: player
    objtype: Sprite
startscreen: main
title: Space Aliens
workstates:
  Mothership: !!python/object:game.WorkState
    actions: {1: 'self.resize(0,0)

        self.x=0

        self.y=0

        self.player_dead = 0

        self.avx = 100

        self.aliendist = 3


        self.set_timer(self.aliendist)

        pass', 3: "\\n# Check for collisions\\ncollisions = gamescreen.get_collisions(gamescreen.vars.get(\\"\\
        aliens\\",{}).keys(),gamescreen.vars.get(\\"bullets\\",{}).keys())\\nfor (name1,name2)\\
        \\ in  collisions:\\n  if name1[:6] == \\"bullet\\":\\n    gamescreen.get_object(name1).destroy()\\n\\
        \\    gamescreen.get_object(name2).workstate = \\"ws_alien_die\\"\\n  else:\\n\\
        \\    gamescreen.get_object(name2).destroy()\\n    gamescreen.get_object(name1).workstate\\
        \\ = \\"ws_alien_die\\"\\n\\n", 11: '

        # Create a new alien

        name = "alien" + str(int(random.random() * 500))

        a = gamescreen.add_object("Alien", name )

        gamescreen.get_object(name).vx = self.avx

        self.avx = self.avx + 2


        gamescreen.vars.setdefault("aliens",{})[name] = 1


        self.set_timer(self.aliendist)

        self.aliendist = self.aliendist * 0.999


        '}
    inherits: null
    objtype: Workstate
  ws_alien: !!python/object:game.WorkState
    actions: {1: 'self.x=0

        self.y=0

        self.resize(55,43)

        # self.vx = 100 ''now set by mother ship

        self.vy = 0


        pass', 3: 'self.move_velocity()

        ', 9: "\\nself.vx = -self.vx\\n\\nself.y = self.y + self.height + 20\\n\\nif self.y\\
        \\ > 600:\\n   self.destroy()"}
    inherits: null
    objtype: Workstate
  ws_alien_die: !!python/object:game.WorkState
    actions: {1: 'self.sprite="aliendying"


        self.set_timer(0.75)', 11: "for i in range(5):\\n    name = \\"fire\\" + str(random.random())\\n\\
        \\    ball = gamescreen.add_object(\\"Fireball\\",name)\\n    ball.name = name\\n\\
        \\    ball.x = self.x\\n    ball.y = self.y\\n\\ngame.score+=1\\nself.destroy()"}
    inherits: ws_alien
    objtype: Workstate
  ws_bullet: !!python/object:game.WorkState
    actions: {1: "self.vx=0 \\nself.vy = -250\\nself.z = -1\\nself.color = (200,50,50)\\n\\
        self.clear()\\npass", 3: '

        self.move_velocity()', 9: '

        self.destroy()'}
    inherits: null
    objtype: Workstate
  ws_fireball: !!python/object:game.WorkState
    actions: {1: 'self.resize(60,42)

        self.vx = (random.random() * 120) - 60

        self.vy = (random.random() * 120) - 60


        self.set_timer((0.5 + random.random()* 3))', 3: "\\nself.move_velocity()\\n\\
        self.vy = self.vy + 5\\n\\nif gamescreen.get_object(\\"MotherShip\\").player_dead\\
        \\ == 0:\\n\\n   if gamescreen.check_collisions(\\"Player\\",self.name):\\n    \\
        \\  gamescreen.get_object(\\"MotherShip\\").player_dead = 1\\n      gamescreen.get_object(\\"\\
        Player\\").workstate = \\"ws_player_die\\"", 9: self.destroy(), 11: 'self.destroy()

        pass'}
    inherits: null
    objtype: Workstate
  ws_player: !!python/object:game.WorkState
    actions: {-552: '

        self.vx=0', -550: '

        self.vx=0', 1: 'self.x = 300

        self.y = 550

        self.vx=0

        self.vy=0

        self.resize(55,33)

        self.canfire=True

        pass', 3: '

        self.move_velocity()', 9: "\\nif self.x > gamescreen.width:\\n\\tself.x = gamescreen.width\\n\\
        else:\\n\\tself.x = 0 - self.width", 11: '

        self.canfire=True', 546: "if self.canfire:\\n   bullet = \\"bullet\\" + str(int(random.random()\\
        \\ * 100))\\n   obj = gamescreen.add_object(\\"Bullet\\",bullet)\\n   obj.x = self.x\\
        \\ + (self.width/2)\\n   obj.y = self.y\\n   gamescreen.vars.setdefault(\\"bullets\\"\\
        ,{})[bullet] = 1\\n   self.canfire=False\\n   self.set_timer(0.7)\\nelse:\\n \\
        \\  pass\\n\\n", 550: '

        self.vx=100', 552: '

        self.vx=-100'}
    inherits: null
    objtype: Workstate
  ws_player_die: !!python/object:game.WorkState
    actions: {1: "for i in range(5):\\n    name = \\"fire\\" + str(random.random())\\n\\
        \\    ball = gamescreen.add_object(\\"Fireball\\",name)\\n    ball.name = name\\n\\
        \\    ball.x = self.x\\n    ball.y = self.y\\n\\nself.destroy()"}
    inherits: null
    objtype: Workstate
  ws_score: !!python/object:game.WorkState
    actions: {1: 'self.resize(60,22)

        self.color=gamescreen.color

        self.z=-1

        pass', 3: '

        self.clear()

        self.draw_text("Score: %s"%game.score,size=20,colour=(255,255,255))'}
    inherits: null
    objtype: Workstate

"""
if __name__ == "__main__":
  import gbfileio,sys,runtime
  game = gbfileio.loadgame(sys.argv[0])
  runtime.run_game(game)
